xenoprof: flush remaining smples when sampling is stopped.
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 10:25:00 +0000 (10:25 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 14 Dec 2007 10:25:00 +0000 (10:25 +0000)
Xenoprof notifies guest kernel via VIRQ_XENOPROF when sampled.
But it does coarsly based on heuristic so that sometimes VIRQ_XENOPROF
isn't delivered resulting in that oprofile daemon collects no sample.
To avoid that situation, always send VIRQ_XENOPROF when sampling is
stopped.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
xen/common/xenoprof.c

index fee2a6556b079a2f2efa3d9a8bc1e85e49bce3dd..741c9f04d3c1f631debae01877c489f81c2a2f92 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef COMPAT
 #include <xen/guest_access.h>
 #include <xen/sched.h>
+#include <xen/event.h>
 #include <public/xenoprof.h>
 #include <xen/paging.h>
 #include <xsm/xsm.h>
@@ -747,14 +748,30 @@ int do_xenoprof_op(int op, XEN_GUEST_HANDLE(void) arg)
         break;
 
     case XENOPROF_stop:
+    {
+        struct domain *d;
+        struct vcpu *v;
+        int i;
+
         if ( xenoprof_state != XENOPROF_PROFILING )
         {
             ret = -EPERM;
             break;
         }
         xenoprof_arch_stop();
+
+        /* Flush remaining samples. */
+        for ( i = 0; i < adomains; i++ )
+        {
+            if ( !active_ready[i] )
+                continue;
+            d = active_domains[i];
+            for_each_vcpu(d, v)
+                send_guest_vcpu_virq(v, VIRQ_XENOPROF);
+        }
         xenoprof_state = XENOPROF_READY;
         break;
+    }
 
     case XENOPROF_disable_virq:
     {